import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:jd_flutter/base/pre_init/pre_init.dart';
import 'package:jd_flutter/modules/pages/main/splash_page.dart';

import 'base/utils/jd_log.dart';
import 'modules/config/app_init_config.dart';

main() {
  darLearn();
  // setUpApp()
}

darLearn() {
  // 1 基础语法
  // DartBasic dartBasic = DartBasic();
  // dartBasic.helloDemo();

  // 2 继承
  // Student student = Student();
  // student.eat();

  // 3 UI
  // student.mixinTest();

  // IsolateDemo().startNewIsolate();
  // runApp(const MyApp());

  setUpApp();
}

setUpApp() {
  initApplication() {
    return PreInit(
      initCompleteCallback: (packageInfo) {
        //启动前的配置, 不重要的可以延时初始化
        AppInitConfig.instance.initConfig();
      },
      homePage: (BuildContext context) {
        return const SplashPage();
      },
    );
  }

  runZonedGuarded(() {
    runApp(initApplication.call());
  }, (error, stackTrace) {
    jdLog(
        'runZonedGuarded:error--->  ${error.toString()}  stackTrace---> ${stackTrace.toString()}');
    if (kReleaseMode) {
      // FlutterBuglyPlugin.reportException(
      //     exceptionName: error.toString(), reason: stackTrace.toString());
    }
  });
}
